Skip to content

Fix profile save update semantics#8455

Open
AndyLow91 wants to merge 1 commit intonightscout:devfrom
AndyLow91:dev
Open

Fix profile save update semantics#8455
AndyLow91 wants to merge 1 commit intonightscout:devfrom
AndyLow91:dev

Conversation

@AndyLow91
Copy link
Member

Regression found from dev branch. When saving a profile, I'm seeing:

MongoServerError: E11000 duplicate key error collection: thibault.profile index: _id_ dup key: { _id: ObjectId('69b926c87fd3539b8414c63f') }
at /opt/app/node_modules/mongodb/lib/operations/insert.js:50:33
at process.processTicksAndRejections (node:internal/process/task_queues:103:5) {
index: 0,
code: 11000,
keyPattern: { _id: 1 },
keyValue: { _id: new ObjectId("69b926c87fd3539b8414c63f") },
[Symbol(errorLabels)]: Set(0) {}
}

The change appears to have been introduced by commit 286fa07014dca75b089dd6fc923ee14e78866bf5 with message switch profile api to new mongo driver.

This change safely normalizes or generates _id, then uses replaceOne({ _id }, obj, { upsert: true }) instead of insertOne(obj).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant